﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace Acme.BookStore2.Migrations
{
    public partial class vehicleattach2 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_AppVehicle_AttachFiles_AppVehicle_OwnerId",
                table: "AppVehicle_AttachFiles");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AppVehicle_AttachFiles",
                table: "AppVehicle_AttachFiles");

            migrationBuilder.RenameTable(
                name: "AppVehicle_AttachFiles",
                newName: "AppAttachFile");

            migrationBuilder.RenameIndex(
                name: "IX_AppVehicle_AttachFiles_OwnerId",
                table: "AppAttachFile",
                newName: "IX_AppAttachFile_OwnerId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AppAttachFile",
                table: "AppAttachFile",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_AppAttachFile_AppVehicle_OwnerId",
                table: "AppAttachFile",
                column: "OwnerId",
                principalTable: "AppVehicle",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_AppAttachFile_AppVehicle_OwnerId",
                table: "AppAttachFile");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AppAttachFile",
                table: "AppAttachFile");

            migrationBuilder.RenameTable(
                name: "AppAttachFile",
                newName: "AppVehicle_AttachFiles");

            migrationBuilder.RenameIndex(
                name: "IX_AppAttachFile_OwnerId",
                table: "AppVehicle_AttachFiles",
                newName: "IX_AppVehicle_AttachFiles_OwnerId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AppVehicle_AttachFiles",
                table: "AppVehicle_AttachFiles",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_AppVehicle_AttachFiles_AppVehicle_OwnerId",
                table: "AppVehicle_AttachFiles",
                column: "OwnerId",
                principalTable: "AppVehicle",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
